package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.StudentBean;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private IStudentMapper mapper;
    @Override
    public PageInfo<StudentBean> findByItem(int pageNO, String name, Integer startGrade, Integer endGrade) {
        PageHelper.startPage(pageNO,PAGESIZE);
        PageInfo<StudentBean> pageInfo = PageInfo.of(mapper.findByItem(name,startGrade,endGrade));
        return pageInfo;
    }

    @Override
    public void add(StudentBean student) {
        mapper.add(student);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, String phone, int classId) {
        mapper.update(id,phone,classId);
    }

    @Override
    public StudentBean findById(int id) {
        return mapper.findById(id);
    }
}
